module Texture {
	export class NineGridTest extends egret.DisplayObjectContainer{
		private _bmpUse9Scale:egret.Bitmap;
		private _bmpNouse9Scale:egret.Bitmap;

		public constructor() {
			super();
			this.once(egret.Event.ADDED_TO_STAGE,this.onAddedToStage,this);
		}

		private onAddedToStage(evt): void {
			RES.getResByUrl("resource/roundRect.jpg", (texture: egret.Texture): void => {
				this._bmpNouse9Scale = new egret.Bitmap(texture);
				this._bmpUse9Scale = new egret.Bitmap(texture);
				this.addChild(this._bmpNouse9Scale);
				this.addChild(this._bmpUse9Scale);
				this._bmpNouse9Scale.anchorOffsetX = this._bmpNouse9Scale.width / 2;
				this._bmpNouse9Scale.anchorOffsetY = this._bmpNouse9Scale.height / 2;
				this._bmpUse9Scale.anchorOffsetX = this._bmpUse9Scale.width / 2;
				this._bmpUse9Scale.anchorOffsetY = this._bmpUse9Scale.height / 2;
				this._bmpNouse9Scale.x = this.stage.stageWidth / 2;
				this._bmpNouse9Scale.y = this.stage.stageHeight * .3;
				this._bmpUse9Scale.x = this.stage.stageWidth / 2;
				this._bmpUse9Scale.y = this.stage.stageHeight * .7;

				this._bmpUse9Scale.scale9Grid=new egret.Rectangle(40,40,120,120);

				egret.Tween.get(this._bmpNouse9Scale, {
					loop: true, onChange: () => {
						this._bmpNouse9Scale.anchorOffsetX = this._bmpNouse9Scale.width / 2;
						this._bmpNouse9Scale.anchorOffsetY = this._bmpNouse9Scale.height / 2;
					}
				})
					.to({ width: L.W_UI_MAX, height: L.H_UI_MIN }, 500)
					.to({ width: L.W_UI_MIN, height: L.H_UI_MAX }, 500)
					.to({ width: L.W_UI_NORMAL, height: L.H_UI_NORMAL }, 500);

				egret.Tween.get(this._bmpUse9Scale, {
					loop: true, onChange: () => {
						this._bmpUse9Scale.anchorOffsetX = this._bmpUse9Scale.width / 2;
						this._bmpUse9Scale.anchorOffsetY = this._bmpUse9Scale.height / 2;
					}
				})
					.to({ width: L.W_UI_MAX, height: L.H_UI_MIN }, 500)
					.to({ width: L.W_UI_MIN, height: L.H_UI_MAX }, 500)
					.to({ width: L.W_UI_NORMAL, height: L.H_UI_NORMAL }, 500);

			}, this, RES.ResourceItem.TYPE_IMAGE);
		}
	}

	/// 布局定义
	class L {
		public static GAP_UNIFIED: number = 10;
		public static W_UI_NORMAL:number=200;
		public static H_UI_NORMAL:number=220;
		public static W_UI_MAX: number=360;
		public static H_UI_MAX: number=360;
		public static W_UI_MIN: number = 120;
		public static H_UI_MIN: number = 120;
	}
}